Skip to content

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Oct 12, 2025

The sys/types.h header is part of POSIX, which is optional in Zephyr and is mostly unimplemented by Zephyr's minimal C library.

Additionally, the only reason sys/types.h is included in string.c (in the minimal libc) is because of the non-standard mem_word_t type.

mem_word_t is not used anywhere else in-tree or in modules hosted by the Zephyr project. It is only used in string.c in the minimal c library.

It's definitely not specified here https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html and so does not really belong in sys/types.h.

Move mem_word_t into the minimal libc's string.c. If needed, it can be removed at a later date and switched for uintptr_t.

@cfriedt cfriedt force-pushed the drop-sys-types-from-minimal-memset branch from e1efb17 to 70512a4 Compare October 12, 2025 13:58
@cfriedt
Copy link
Member Author

cfriedt commented Oct 12, 2025

  • fixed code sonar warning
    • changed s_byte = (unsigned char *)s_word; to s_byte = (const unsigned char *)s_word;

@cfriedt cfriedt marked this pull request as ready for review October 12, 2025 14:49
@cfriedt cfriedt added the area: Minimal libc Minimal C Standard Library label Oct 12, 2025
@zephyrbot zephyrbot added the area: C Library C Standard Library label Oct 12, 2025
@cfriedt cfriedt requested a review from ycsin October 13, 2025 15:14
@ycsin ycsin requested a review from npitre October 13, 2025 15:34
@ycsin
Copy link
Member

ycsin commented Oct 13, 2025

This was introduced in 03170c0, cc @npitre

Copy link

@npitre npitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest moving the mem_word_t definition & comment at the top
of string.c instead.

The `sys/types.h` header is part of POSIX, which is optional in Zephyr and
is mostly unimplemented by Zephyr's minimal C library.

Additionally, the only reason `sys/types.h` is included in `string.c` (in
the minimal libc) is because of the non-standard `mem_word_t` type.

`mem_word_t` is not used anywhere else in-tree or in modules hosted by the
Zephyr project. It is only used in `string.c` in the minimal c library.

It's definitely not specified here
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
and so does not really belong in `sys/types.h`.

Move `mem_word_t` into the minimal libc's `string.c`. If needed, it can be
removed at a later date and switched for `uintptr_t`.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt force-pushed the drop-sys-types-from-minimal-memset branch from 70512a4 to 5d5782d Compare October 14, 2025 15:07
@cfriedt cfriedt changed the title libc: minimal: string: drop sys/types.h and mem_word_t libc: minimal: sys/types.h: move mem_word_t to string.c Oct 14, 2025
@cfriedt
Copy link
Member Author

cfriedt commented Oct 14, 2025

@npitre - fixed!

@cfriedt cfriedt requested a review from npitre October 14, 2025 15:08
Copy link

@jhedberg jhedberg merged commit c617ede into zephyrproject-rtos:main Oct 15, 2025
30 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: C Library C Standard Library area: Minimal libc Minimal C Standard Library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants